package com.lindroy.androidplayer.viewmodels

import androidx.lifecycle.ViewModel
import com.lindroy.androidplayer.R
import java.lang.NumberFormatException

/**
 * @author Lin
 * @date 2022/2/14
 * @function
 */
data class CoinRankingItemViewModel(
    val coinCount: Int = 0,
    val level: Int = 0,
    val nickname: String = "",
    val rank: String = "",
    val userId: Int = 0,
    val username: String = ""
) : ViewModel() {

    val isShowRankingBg: Boolean
        get() = try {
            rank.toInt() <= 3
        } catch (e: NumberFormatException) {
            false
        }

    val rankingBackgroundRes: Int
        get() = when (rank) {
            "1" -> R.drawable.ic_rank1
            "2" -> R.drawable.ic_rank2
            "3" -> R.drawable.ic_rank3
            else -> 0
        }

}